﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

namespace RuntimeGizmos
{
	// Token: 0x0200016D RID: 365
	[RequireComponent(typeof(Camera))]
	public class TransformGizmo : MonoBehaviour
	{
		// Token: 0x06000691 RID: 1681 RVA: 0x00038B2D File Offset: 0x00036D2D
		private void Awake()
		{
			this.myCamera = base.GetComponent<Camera>();
			this.SetMaterial();
		}

		// Token: 0x06000692 RID: 1682 RVA: 0x00038B44 File Offset: 0x00036D44
		private void Update()
		{
			this.SetSpaceAndType();
			this.SelectAxis();
			this.GetTarget();
			if (this.target != null)
			{
				this.TransformSelected();
				if (Input.GetKeyDown(KeyCode.R) && Input.GetKey(KeyCode.LeftShift) && this.target.GetComponent<FingerPoserHandle>() != null)
				{
					this.target.GetComponent<FingerPoserHandle>().Reset();
				}
			}
		}

		// Token: 0x06000693 RID: 1683 RVA: 0x00038BBB File Offset: 0x00036DBB
		private void LateUpdate()
		{
			if (this.target == null)
			{
				return;
			}
			this.SetAxisInfo();
			this.SetLines();
		}

		// Token: 0x06000694 RID: 1684 RVA: 0x00038BDB File Offset: 0x00036DDB
		private bool MouseOverUI()
		{
			return EventSystem.current.IsPointerOverGameObject();
		}

		// Token: 0x06000695 RID: 1685 RVA: 0x00038BE8 File Offset: 0x00036DE8
		private void OnPostRender()
		{
			if (this.target == null)
			{
				return;
			}
			TransformGizmo.lineMaterial.SetPass(0);
			Color color = (this.selectedAxis != Axis.X) ? this.xColor : this.selectedColor;
			Color color2 = (this.selectedAxis != Axis.Y) ? this.yColor : this.selectedColor;
			Color color3 = (this.selectedAxis != Axis.Z) ? this.zColor : this.selectedColor;
			Color color4 = (this.selectedAxis != Axis.Any) ? this.allColor : this.selectedColor;
			this.DrawLines(this.handleLines.x, color);
			this.DrawLines(this.handleLines.y, color2);
			this.DrawLines(this.handleLines.z, color3);
			this.DrawTriangles(this.handleTriangles.x, color);
			this.DrawTriangles(this.handleTriangles.y, color2);
			this.DrawTriangles(this.handleTriangles.z, color3);
			this.DrawSquares(this.handleSquares.x, color);
			this.DrawSquares(this.handleSquares.y, color2);
			this.DrawSquares(this.handleSquares.z, color3);
			this.DrawSquares(this.handleSquares.all, color4);
			AxisVectors axisVectors = this.circlesLines;
			if (this.space == TransformSpace.Global && this.type == TransformType.Rotate)
			{
				axisVectors = this.drawCurrentCirclesLines;
				this.SetCircles(new AxisInfo
				{
					xDirection = this.totalRotationAmount * Vector3.right,
					yDirection = this.totalRotationAmount * Vector3.up,
					zDirection = this.totalRotationAmount * Vector3.forward
				}, this.drawCurrentCirclesLines);
			}
			this.DrawCircles(axisVectors.x, color);
			this.DrawCircles(axisVectors.y, color2);
			this.DrawCircles(axisVectors.z, color3);
			this.DrawCircles(axisVectors.all, color4);
		}

		// Token: 0x06000696 RID: 1686 RVA: 0x00038DFC File Offset: 0x00036FFC
		private void SetSpaceAndType()
		{
			if (Input.GetKeyDown(this.SetMoveType))
			{
				this.SetToolMode(TransformType.Move);
			}
			else if (Input.GetKeyDown(this.SetRotateType))
			{
				this.SetToolMode(TransformType.Rotate);
			}
			else if (Input.GetKeyDown(this.SetScaleType))
			{
				this.SetToolMode(TransformType.Scale);
			}
			if (Input.GetButtonDown(ButtonInput.ToggleTransformSpace))
			{
				this.ToggleSpaceMode();
			}
			if (this.type == TransformType.Scale && !this.overrideSpace)
			{
				this.space = TransformSpace.Local;
			}
		}

		// Token: 0x06000697 RID: 1687 RVA: 0x00038E8B File Offset: 0x0003708B
		public void SetToolMode(TransformType mode)
		{
			if (!this.allowScaling && mode == TransformType.Scale)
			{
				return;
			}
			this.type = mode;
		}

		// Token: 0x06000698 RID: 1688 RVA: 0x00038EA7 File Offset: 0x000370A7
		public void ToggleSpaceMode()
		{
			if (this.overrideSpace)
			{
				return;
			}
			if (this.space == TransformSpace.Global)
			{
				this.space = TransformSpace.Local;
			}
			else if (this.space == TransformSpace.Local)
			{
				this.space = TransformSpace.Global;
			}
		}

		// Token: 0x06000699 RID: 1689 RVA: 0x00038EE0 File Offset: 0x000370E0
		private void TransformSelected()
		{
			float time = Time.time;
			if (Input.GetMouseButtonDown(0))
			{
				this.startClick = time;
			}
			if (this.startClick > 0f && time > this.startClick + this.minClickTime)
			{
				this.startClick = -1f;
				if (this.selectedAxis != Axis.None && Input.GetMouseButton(0) && !this.MouseOverUI())
				{
					base.StartCoroutine(this.TransformSelected(this.type));
				}
			}
		}

		// Token: 0x0600069A RID: 1690 RVA: 0x00038F68 File Offset: 0x00037168
		private IEnumerator TransformSelected(TransformType type)
		{
			this.isTransforming = true;
			this.totalScaleAmount = 0f;
			this.totalRotationAmount = Quaternion.identity;
			Vector3 originalTargetPosition = this.GetTargetPosition();
			Vector3 planeNormal = (base.transform.position - this.GetTargetPosition()).normalized;
			Vector3 axis = this.GetSelectedAxisDirection();
			Vector3 projectedAxis = Vector3.ProjectOnPlane(axis, planeNormal).normalized;
			Vector3 previousMousePosition = Vector3.zero;
			while (!Input.GetMouseButtonUp(0))
			{
				Ray mouseRay = this.myCamera.ScreenPointToRay(Input.mousePosition);
				Vector3 mousePosition = Geometry.LinePlaneIntersect(mouseRay.origin, mouseRay.direction, originalTargetPosition, planeNormal);
				if (previousMousePosition != Vector3.zero && mousePosition != Vector3.zero)
				{
					if (type == TransformType.Move)
					{
						float d = ExtVector3.MagnitudeInDirection(mousePosition - previousMousePosition, projectedAxis, true) * this.moveSpeedMultiplier;
						if (this.entity != null)
						{
							this.entity.Move(this.entity.realPosition + axis * d);
						}
						else
						{
							this.target.Translate(axis * d, Space.World);
						}
					}
					if (type == TransformType.Scale)
					{
						Vector3 direction = (this.selectedAxis != Axis.Any) ? projectedAxis : base.transform.right;
						float num = ExtVector3.MagnitudeInDirection(mousePosition - previousMousePosition, direction, true) * this.scaleSpeedMultiplier;
						Vector3 a = (this.space != TransformSpace.Local || this.selectedAxis == Axis.Any) ? axis : this.target.InverseTransformDirection(axis);
						if (this.selectedAxis == Axis.Any)
						{
							this.target.localScale += this.target.localScale.normalized.Abs() * num;
						}
						else
						{
							this.target.localScale += a * num;
						}
						this.totalScaleAmount += num;
					}
					if (type == TransformType.Rotate)
					{
						if (this.selectedAxis == Axis.Any)
						{
							Vector3 a2 = base.transform.TransformDirection(new Vector3(Input.GetAxis("Mouse Y"), -Input.GetAxis("Mouse X"), 0f));
							this.target.Rotate(a2 * this.allRotateSpeedMultiplier, Space.World);
							this.totalRotationAmount *= Quaternion.Euler(a2 * this.allRotateSpeedMultiplier);
						}
						else
						{
							Vector3 direction2 = (this.selectedAxis != Axis.Any && !ExtVector3.IsParallel(axis, planeNormal, 0.0001f)) ? Vector3.Cross(axis, planeNormal) : planeNormal;
							float num2 = ExtVector3.MagnitudeInDirection(mousePosition - previousMousePosition, direction2, true) * this.rotateSpeedMultiplier / this.GetDistanceMultiplier();
							this.target.Rotate(axis, num2, Space.World);
							this.totalRotationAmount *= Quaternion.Euler(axis * num2);
						}
					}
				}
				previousMousePosition = mousePosition;
				yield return null;
			}
			this.totalRotationAmount = Quaternion.identity;
			this.totalScaleAmount = 0f;
			this.isTransforming = false;
			yield break;
		}

		// Token: 0x0600069B RID: 1691 RVA: 0x00038F8C File Offset: 0x0003718C
		private Vector3 GetSelectedAxisDirection()
		{
			if (this.selectedAxis != Axis.None)
			{
				if (this.selectedAxis == Axis.X)
				{
					return this.axisInfo.xDirection;
				}
				if (this.selectedAxis == Axis.Y)
				{
					return this.axisInfo.yDirection;
				}
				if (this.selectedAxis == Axis.Z)
				{
					return this.axisInfo.zDirection;
				}
				if (this.selectedAxis == Axis.Any)
				{
					return Vector3.one;
				}
			}
			return Vector3.zero;
		}

		// Token: 0x0600069C RID: 1692 RVA: 0x00039004 File Offset: 0x00037204
		private void GetTarget()
		{
			if (!this.getTarget || this.MouseOverUI())
			{
				return;
			}
			if (this.selectedAxis == Axis.None && Input.GetMouseButtonDown(0))
			{
				RaycastHit raycastHit;
				if (Physics.Raycast(this.myCamera.ScreenPointToRay(Input.mousePosition), out raycastHit))
				{
					this.SetTarget(raycastHit.transform);
				}
				else
				{
					this.target = null;
				}
			}
		}

		// Token: 0x0600069D RID: 1693 RVA: 0x00039073 File Offset: 0x00037273
		public void SetTarget(Transform newTarget)
		{
			this.target = newTarget;
			if (this.target)
			{
				this.entity = this.target.GetComponent<EntityBase>();
			}
			else
			{
				this.entity = null;
			}
		}

		// Token: 0x0600069E RID: 1694 RVA: 0x000390A9 File Offset: 0x000372A9
		private Vector3 GetTargetPosition()
		{
			if (this.target.GetComponent<FingerPoserHandle>() != null)
			{
				return this.target.GetComponent<FingerPoserHandle>().realPosition;
			}
			return this.target.position;
		}

		// Token: 0x0600069F RID: 1695 RVA: 0x000390E0 File Offset: 0x000372E0
		private void SelectAxis()
		{
			if (!Input.GetMouseButtonDown(0))
			{
				return;
			}
			this.selectedAxis = Axis.None;
			float num = float.MaxValue;
			float num2 = float.MaxValue;
			float num3 = float.MaxValue;
			float num4 = float.MaxValue;
			float num5 = this.minSelectedDistanceCheck * this.GetDistanceMultiplier();
			if (this.type == TransformType.Move || this.type == TransformType.Scale)
			{
				this.selectedLinesBuffer.Clear();
				this.selectedLinesBuffer.Add(this.handleLines);
				if (this.type == TransformType.Move)
				{
					this.selectedLinesBuffer.Add(this.handleTriangles);
				}
				else if (this.type == TransformType.Scale)
				{
					this.selectedLinesBuffer.Add(this.handleSquares);
				}
				num = this.ClosestDistanceFromMouseToLines(this.selectedLinesBuffer.x);
				num2 = this.ClosestDistanceFromMouseToLines(this.selectedLinesBuffer.y);
				num3 = this.ClosestDistanceFromMouseToLines(this.selectedLinesBuffer.z);
				num4 = this.ClosestDistanceFromMouseToLines(this.selectedLinesBuffer.all);
			}
			else if (this.type == TransformType.Rotate)
			{
				num = this.ClosestDistanceFromMouseToLines(this.circlesLines.x);
				num2 = this.ClosestDistanceFromMouseToLines(this.circlesLines.y);
				num3 = this.ClosestDistanceFromMouseToLines(this.circlesLines.z);
				num4 = this.ClosestDistanceFromMouseToLines(this.circlesLines.all);
			}
			if (this.type == TransformType.Scale && num4 <= num5)
			{
				this.selectedAxis = Axis.Any;
			}
			else if (num <= num5 && num <= num2 && num <= num3)
			{
				this.selectedAxis = Axis.X;
			}
			else if (num2 <= num5 && num2 <= num && num2 <= num3)
			{
				this.selectedAxis = Axis.Y;
			}
			else if (num3 <= num5 && num3 <= num && num3 <= num2)
			{
				this.selectedAxis = Axis.Z;
			}
			else if (this.type == TransformType.Rotate && this.target != null)
			{
				Ray ray = this.myCamera.ScreenPointToRay(Input.mousePosition);
				Vector3 b = Geometry.LinePlaneIntersect(ray.origin, ray.direction, this.GetTargetPosition(), (base.transform.position - this.GetTargetPosition()).normalized);
				if ((this.GetTargetPosition() - b).sqrMagnitude <= (this.handleLength * this.GetDistanceMultiplier()).Squared())
				{
					this.selectedAxis = Axis.Any;
				}
			}
		}

		// Token: 0x060006A0 RID: 1696 RVA: 0x0003935C File Offset: 0x0003755C
		private float ClosestDistanceFromMouseToLines(List<Vector3> lines)
		{
			Ray ray = this.myCamera.ScreenPointToRay(Input.mousePosition);
			float num = float.MaxValue;
			for (int i = 0; i < lines.Count; i += 2)
			{
				IntersectPoints intersectPoints = Geometry.ClosestPointsOnSegmentToLine(lines[i], lines[i + 1], ray.origin, ray.direction);
				float num2 = Vector3.Distance(intersectPoints.first, intersectPoints.second);
				if (num2 < num)
				{
					num = num2;
				}
			}
			return num;
		}

		// Token: 0x060006A1 RID: 1697 RVA: 0x000393DC File Offset: 0x000375DC
		private void SetAxisInfo()
		{
			float num = this.handleLength * this.GetDistanceMultiplier();
			this.axisInfo.Set(this.target, num, this.space);
			if (this.isTransforming && this.type == TransformType.Scale)
			{
				if (this.selectedAxis == Axis.Any)
				{
					this.axisInfo.Set(this.target, num + this.totalScaleAmount, this.space);
				}
				if (this.selectedAxis == Axis.X)
				{
					this.axisInfo.xAxisEnd = this.axisInfo.xAxisEnd + this.axisInfo.xDirection * this.totalScaleAmount;
				}
				if (this.selectedAxis == Axis.Y)
				{
					this.axisInfo.yAxisEnd = this.axisInfo.yAxisEnd + this.axisInfo.yDirection * this.totalScaleAmount;
				}
				if (this.selectedAxis == Axis.Z)
				{
					this.axisInfo.zAxisEnd = this.axisInfo.zAxisEnd + this.axisInfo.zDirection * this.totalScaleAmount;
				}
			}
		}

		// Token: 0x060006A2 RID: 1698 RVA: 0x000394FC File Offset: 0x000376FC
		private float GetDistanceMultiplier()
		{
			if (this.target == null)
			{
				return 0f;
			}
			return Mathf.Max(0.01f, Mathf.Abs(ExtVector3.MagnitudeInDirection(this.GetTargetPosition() - base.transform.position, this.myCamera.transform.forward, true)));
		}

		// Token: 0x060006A3 RID: 1699 RVA: 0x0003955B File Offset: 0x0003775B
		private void SetLines()
		{
			this.SetHandleLines();
			this.SetHandleTriangles();
			this.SetHandleSquares();
			this.SetCircles(this.axisInfo, this.circlesLines);
		}

		// Token: 0x060006A4 RID: 1700 RVA: 0x00039584 File Offset: 0x00037784
		private void SetHandleLines()
		{
			this.handleLines.Clear();
			if (this.type == TransformType.Move || this.type == TransformType.Scale)
			{
				this.handleLines.x.Add(this.GetTargetPosition());
				this.handleLines.x.Add(this.axisInfo.xAxisEnd);
				this.handleLines.y.Add(this.GetTargetPosition());
				this.handleLines.y.Add(this.axisInfo.yAxisEnd);
				this.handleLines.z.Add(this.GetTargetPosition());
				this.handleLines.z.Add(this.axisInfo.zAxisEnd);
			}
		}

		// Token: 0x060006A5 RID: 1701 RVA: 0x00039648 File Offset: 0x00037848
		private void SetHandleTriangles()
		{
			this.handleTriangles.Clear();
			if (this.type == TransformType.Move)
			{
				float size = this.triangleSize * this.GetDistanceMultiplier();
				this.AddTriangles(this.axisInfo.xAxisEnd, this.axisInfo.xDirection, this.axisInfo.yDirection, this.axisInfo.zDirection, size, this.handleTriangles.x);
				this.AddTriangles(this.axisInfo.yAxisEnd, this.axisInfo.yDirection, this.axisInfo.xDirection, this.axisInfo.zDirection, size, this.handleTriangles.y);
				this.AddTriangles(this.axisInfo.zAxisEnd, this.axisInfo.zDirection, this.axisInfo.yDirection, this.axisInfo.xDirection, size, this.handleTriangles.z);
			}
		}

		// Token: 0x060006A6 RID: 1702 RVA: 0x00039734 File Offset: 0x00037934
		private void AddTriangles(Vector3 axisEnd, Vector3 axisDirection, Vector3 axisOtherDirection1, Vector3 axisOtherDirection2, float size, List<Vector3> resultsBuffer)
		{
			Vector3 item = axisEnd + axisDirection * (size * 2f);
			Square baseSquare = this.GetBaseSquare(axisEnd, axisOtherDirection1, axisOtherDirection2, size / 2f);
			resultsBuffer.Add(baseSquare.bottomLeft);
			resultsBuffer.Add(baseSquare.topLeft);
			resultsBuffer.Add(baseSquare.topRight);
			resultsBuffer.Add(baseSquare.topLeft);
			resultsBuffer.Add(baseSquare.bottomRight);
			resultsBuffer.Add(baseSquare.topRight);
			for (int i = 0; i < 4; i++)
			{
				resultsBuffer.Add(baseSquare[i]);
				resultsBuffer.Add(baseSquare[i + 1]);
				resultsBuffer.Add(item);
			}
		}

		// Token: 0x060006A7 RID: 1703 RVA: 0x000397F8 File Offset: 0x000379F8
		private void SetHandleSquares()
		{
			this.handleSquares.Clear();
			if (this.type == TransformType.Scale)
			{
				float num = this.boxSize * this.GetDistanceMultiplier();
				this.AddSquares(this.axisInfo.xAxisEnd, this.axisInfo.xDirection, this.axisInfo.yDirection, this.axisInfo.zDirection, num, this.handleSquares.x);
				this.AddSquares(this.axisInfo.yAxisEnd, this.axisInfo.yDirection, this.axisInfo.xDirection, this.axisInfo.zDirection, num, this.handleSquares.y);
				this.AddSquares(this.axisInfo.zAxisEnd, this.axisInfo.zDirection, this.axisInfo.xDirection, this.axisInfo.yDirection, num, this.handleSquares.z);
				this.AddSquares(this.GetTargetPosition() - this.axisInfo.xDirection * num, this.axisInfo.xDirection, this.axisInfo.yDirection, this.axisInfo.zDirection, num, this.handleSquares.all);
			}
		}

		// Token: 0x060006A8 RID: 1704 RVA: 0x00039934 File Offset: 0x00037B34
		private void AddSquares(Vector3 axisEnd, Vector3 axisDirection, Vector3 axisOtherDirection1, Vector3 axisOtherDirection2, float size, List<Vector3> resultsBuffer)
		{
			Square baseSquare = this.GetBaseSquare(axisEnd, axisOtherDirection1, axisOtherDirection2, size);
			Square baseSquare2 = this.GetBaseSquare(axisEnd + axisDirection * (size * 2f), axisOtherDirection1, axisOtherDirection2, size);
			resultsBuffer.Add(baseSquare.bottomLeft);
			resultsBuffer.Add(baseSquare.topLeft);
			resultsBuffer.Add(baseSquare.bottomRight);
			resultsBuffer.Add(baseSquare.topRight);
			resultsBuffer.Add(baseSquare2.bottomLeft);
			resultsBuffer.Add(baseSquare2.topLeft);
			resultsBuffer.Add(baseSquare2.bottomRight);
			resultsBuffer.Add(baseSquare2.topRight);
			for (int i = 0; i < 4; i++)
			{
				resultsBuffer.Add(baseSquare[i]);
				resultsBuffer.Add(baseSquare[i + 1]);
				resultsBuffer.Add(baseSquare2[i + 1]);
				resultsBuffer.Add(baseSquare2[i]);
			}
		}

		// Token: 0x060006A9 RID: 1705 RVA: 0x00039A30 File Offset: 0x00037C30
		private Square GetBaseSquare(Vector3 axisEnd, Vector3 axisOtherDirection1, Vector3 axisOtherDirection2, float size)
		{
			Vector3 b = axisOtherDirection1 * size + axisOtherDirection2 * size;
			Vector3 b2 = axisOtherDirection1 * size - axisOtherDirection2 * size;
			Square result;
			result.bottomLeft = axisEnd + b2;
			result.topLeft = axisEnd + b;
			result.bottomRight = axisEnd - b2;
			result.topRight = axisEnd - b;
			return result;
		}

		// Token: 0x060006AA RID: 1706 RVA: 0x00039AA4 File Offset: 0x00037CA4
		private void SetCircles(AxisInfo axisInfo, AxisVectors axisVectors)
		{
			axisVectors.Clear();
			if (this.type == TransformType.Rotate)
			{
				float size = this.handleLength * this.GetDistanceMultiplier();
				this.AddCircle(this.GetTargetPosition(), axisInfo.xDirection, size, axisVectors.x, true);
				this.AddCircle(this.GetTargetPosition(), axisInfo.yDirection, size, axisVectors.y, true);
				this.AddCircle(this.GetTargetPosition(), axisInfo.zDirection, size, axisVectors.z, true);
				this.AddCircle(this.GetTargetPosition(), (this.GetTargetPosition() - base.transform.position).normalized, size, axisVectors.all, false);
			}
		}

		// Token: 0x060006AB RID: 1707 RVA: 0x00039B54 File Offset: 0x00037D54
		private void AddCircle(Vector3 origin, Vector3 axisDirection, float size, List<Vector3> resultsBuffer, bool depthTest = true)
		{
			Vector3 vector = axisDirection.normalized * size;
			Vector3 rhs = Vector3.Slerp(vector, -vector, 0.5f);
			Vector3 vector2 = Vector3.Cross(vector, rhs).normalized * size;
			Matrix4x4 matrix4x = default(Matrix4x4);
			matrix4x[0] = vector2.x;
			matrix4x[1] = vector2.y;
			matrix4x[2] = vector2.z;
			matrix4x[4] = vector.x;
			matrix4x[5] = vector.y;
			matrix4x[6] = vector.z;
			matrix4x[8] = rhs.x;
			matrix4x[9] = rhs.y;
			matrix4x[10] = rhs.z;
			Vector3 vector3 = origin + matrix4x.MultiplyPoint3x4(new Vector3(Mathf.Cos(0f), 0f, Mathf.Sin(0f)));
			Vector3 vector4 = Vector3.zero;
			float num = 360f / (float)this.circleDetail;
			Plane plane = new Plane((base.transform.position - this.GetTargetPosition()).normalized, this.GetTargetPosition());
			for (int i = 0; i < this.circleDetail + 1; i++)
			{
				vector4.x = Mathf.Cos((float)i * num * 0.017453292f);
				vector4.z = Mathf.Sin((float)i * num * 0.017453292f);
				vector4.y = 0f;
				vector4 = origin + matrix4x.MultiplyPoint3x4(vector4);
				if (!depthTest || plane.GetSide(vector3))
				{
					resultsBuffer.Add(vector3);
					resultsBuffer.Add(vector4);
				}
				vector3 = vector4;
			}
		}

		// Token: 0x060006AC RID: 1708 RVA: 0x00039D2C File Offset: 0x00037F2C
		private void DrawLines(List<Vector3> lines, Color color)
		{
			GL.Begin(1);
			GL.Color(color);
			for (int i = 0; i < lines.Count; i += 2)
			{
				GL.Vertex(lines[i]);
				GL.Vertex(lines[i + 1]);
			}
			GL.End();
		}

		// Token: 0x060006AD RID: 1709 RVA: 0x00039D7C File Offset: 0x00037F7C
		private void DrawTriangles(List<Vector3> lines, Color color)
		{
			GL.Begin(4);
			GL.Color(color);
			for (int i = 0; i < lines.Count; i += 3)
			{
				GL.Vertex(lines[i]);
				GL.Vertex(lines[i + 1]);
				GL.Vertex(lines[i + 2]);
			}
			GL.End();
		}

		// Token: 0x060006AE RID: 1710 RVA: 0x00039DDC File Offset: 0x00037FDC
		private void DrawSquares(List<Vector3> lines, Color color)
		{
			GL.Begin(7);
			GL.Color(color);
			for (int i = 0; i < lines.Count; i += 4)
			{
				GL.Vertex(lines[i]);
				GL.Vertex(lines[i + 1]);
				GL.Vertex(lines[i + 2]);
				GL.Vertex(lines[i + 3]);
			}
			GL.End();
		}

		// Token: 0x060006AF RID: 1711 RVA: 0x00039E48 File Offset: 0x00038048
		private void DrawCircles(List<Vector3> lines, Color color)
		{
			GL.Begin(1);
			GL.Color(color);
			for (int i = 0; i < lines.Count; i += 2)
			{
				GL.Vertex(lines[i]);
				GL.Vertex(lines[i + 1]);
			}
			GL.End();
		}

		// Token: 0x060006B0 RID: 1712 RVA: 0x00039E97 File Offset: 0x00038097
		private void SetMaterial()
		{
			if (TransformGizmo.lineMaterial == null)
			{
				TransformGizmo.lineMaterial = new Material(Shader.Find("Custom/Lines"));
			}
		}

		// Token: 0x04000ABA RID: 2746
		private bool getTarget;

		// Token: 0x04000ABB RID: 2747
		public TransformSpace space;

		// Token: 0x04000ABC RID: 2748
		public TransformType type;

		// Token: 0x04000ABD RID: 2749
		public KeyCode SetMoveType = KeyCode.T;

		// Token: 0x04000ABE RID: 2750
		public KeyCode SetRotateType = KeyCode.R;

		// Token: 0x04000ABF RID: 2751
		public KeyCode SetScaleType = KeyCode.Y;

		// Token: 0x04000AC0 RID: 2752
		public bool overrideSpace;

		// Token: 0x04000AC1 RID: 2753
		public bool allowScaling = true;

		// Token: 0x04000AC2 RID: 2754
		private Color xColor = new Color(1f, 0f, 0f, 0.8f);

		// Token: 0x04000AC3 RID: 2755
		private Color yColor = new Color(0f, 1f, 0f, 0.8f);

		// Token: 0x04000AC4 RID: 2756
		private Color zColor = new Color(0f, 0f, 1f, 0.8f);

		// Token: 0x04000AC5 RID: 2757
		private Color allColor = new Color(0.7f, 0.7f, 0.7f, 0.8f);

		// Token: 0x04000AC6 RID: 2758
		private Color selectedColor = new Color(1f, 1f, 0f, 0.8f);

		// Token: 0x04000AC7 RID: 2759
		private float handleLength = 0.25f;

		// Token: 0x04000AC8 RID: 2760
		private float triangleSize = 0.03f;

		// Token: 0x04000AC9 RID: 2761
		private float boxSize = 0.01f;

		// Token: 0x04000ACA RID: 2762
		private int circleDetail = 40;

		// Token: 0x04000ACB RID: 2763
		private float minSelectedDistanceCheck = 0.04f;

		// Token: 0x04000ACC RID: 2764
		private float moveSpeedMultiplier = 1f;

		// Token: 0x04000ACD RID: 2765
		private float scaleSpeedMultiplier = 1f;

		// Token: 0x04000ACE RID: 2766
		private float rotateSpeedMultiplier = 200f;

		// Token: 0x04000ACF RID: 2767
		private float allRotateSpeedMultiplier = 20f;

		// Token: 0x04000AD0 RID: 2768
		private AxisVectors handleLines = new AxisVectors();

		// Token: 0x04000AD1 RID: 2769
		private AxisVectors handleTriangles = new AxisVectors();

		// Token: 0x04000AD2 RID: 2770
		private AxisVectors handleSquares = new AxisVectors();

		// Token: 0x04000AD3 RID: 2771
		private AxisVectors circlesLines = new AxisVectors();

		// Token: 0x04000AD4 RID: 2772
		private AxisVectors drawCurrentCirclesLines = new AxisVectors();

		// Token: 0x04000AD5 RID: 2773
		private bool isTransforming;

		// Token: 0x04000AD6 RID: 2774
		private float totalScaleAmount;

		// Token: 0x04000AD7 RID: 2775
		private Quaternion totalRotationAmount;

		// Token: 0x04000AD8 RID: 2776
		private Axis selectedAxis;

		// Token: 0x04000AD9 RID: 2777
		private AxisInfo axisInfo;

		// Token: 0x04000ADA RID: 2778
		private Transform target;

		// Token: 0x04000ADB RID: 2779
		private EntityBase entity;

		// Token: 0x04000ADC RID: 2780
		private Camera myCamera;

		// Token: 0x04000ADD RID: 2781
		private float startClick = -1f;

		// Token: 0x04000ADE RID: 2782
		private float minClickTime = 0.1f;

		// Token: 0x04000ADF RID: 2783
		private static Material lineMaterial;

		// Token: 0x04000AE0 RID: 2784
		private AxisVectors selectedLinesBuffer = new AxisVectors();
	}
}
